package com.ayq.activiti.common.util;

import java.util.Calendar;
import java.util.Date;

/**
 * <p>时间工具类</p>
 *
 * @Author ayq
 * @Date 2021/4/16 14:04
 */
public class DateUtil {

    /**
     *
     * <p>获取今天到12点的时间差</p>
     * <p>方法名:getNextDayTime</p>
     * @Author ayq
     * @Date 2021/4/16 14:12
     * @Param []
     * @Return long
     */
    public static long getNextDayTime() {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_YEAR, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        //当前时间与晚上十二点的秒差
        Long timeOut = (calendar.getTimeInMillis() - System.currentTimeMillis()) / 1000;
        return timeOut;
    }

    public static void main(String[] args) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_YEAR, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        //当前时间与晚上十二点的秒差
        Long timeOut = (calendar.getTimeInMillis() - System.currentTimeMillis()) / 1000;
        Date date = new Date(calendar.getTimeInMillis());
        System.out.println(timeOut / 60 / 60);
    }
}
